<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/jquery.form.js"></script>
    <title>动物识别</title>
</head>
<body>
<h1>动物识别</h1>
<form id="imageform" action="handleImage.php" method="post" enctype="multipart/form-data">
    <input type="hidden" name="type" value="4">
    请选择您要上传的图片：
    <input type="file" name="myFile" /><br /><br />
</form>
<button type="button" id="down">上传</button>
<br /><br />
<div class="info"></div>
<script>
    $(function () {
        $('#down').one('click', function () {
            subbmit();
        })
    });
    function subbmit() {
        $("#imageform").ajaxForm({
            success: function (data) {
                var obj = JSON.parse(data);
                if (obj.status == 1) {
                    for (var value in obj.data) {
                        $('.info').append("动物名称：" + obj.data[value].name + "<br />");
                        $('.info').append("可信度：" + (obj.data[value].score * 100).toFixed(1) + " %<br /><br />");
                    }
                } else {
                    alert(obj.data);
                }
            }
        }).submit();
    }
</script>
</body>
</html>